#include "frmMenuBar.h"
#include "GameSystemManager.h"
#include "GameSceneManager.h"
#include "GameObjectManager.h"
#include "CVelocity.h"
#include "PagingSystem.h"
#include <string>

frmMenuBar::frmMenuBar() {
	subscribeEvents();
	setup();
	fillMapList();
}
frmMenuBar::~frmMenuBar() {

}
	
void frmMenuBar::subscribeEvents() {
	////////////////////////////////////////////////////////////////////////////////////////////////////
	//Subsribe GUI MenuBar events
	CEGUI::Window* btnMenuBarScene = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/Scene");
	btnMenuBarScene->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarScene_click,this));

	CEGUI::Window* btnMenuBarTerrain = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/Terrain");
	btnMenuBarTerrain->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarTerrain_click,this));

	CEGUI::Window* btnMenuBarObjects = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/Objects");
	btnMenuBarObjects->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarObjects_click,this));

	CEGUI::Window* btnMenuBarPaging = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/Paging");
	btnMenuBarPaging->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarPaging_click,this));

	CEGUI::Window* btnMenuBarMultiplayer = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/Multiplayer");
	btnMenuBarMultiplayer->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarMultiplayer_click,this));

	CEGUI::Window* btnMenuBarPhysics = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/Physics");
	btnMenuBarPhysics->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarPhysics_click,this));

	CEGUI::Window* btnMenuBarBrushDeform = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/brushDeform");
	btnMenuBarBrushDeform->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarBrushDeform_click,this));
	
	CEGUI::Window* btnMenuBarBrushPaint = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/brushPaint");
	btnMenuBarBrushPaint->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarBrushPaint_click,this));

	CEGUI::Window* btnMenuBarBrushPaging = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/brushPaging");
	btnMenuBarBrushPaging->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarBrushPaging_click,this));

	CEGUI::Window* btnMenuBarBrushObject = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/brushObject");
	btnMenuBarBrushObject->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarBrushObject_click,this));

	CEGUI::Window* btnMenuBarRenderNormal = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/renderNormal");
	btnMenuBarRenderNormal->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarRenderNormal_click,this));
	
	CEGUI::Window* btnMenuBarRenderWireframe = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/renderWireframe");
	btnMenuBarRenderWireframe->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarRenderWireframe_click,this));

	CEGUI::Window* btnMenuBarRenderFPS = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/renderFPS");
	btnMenuBarRenderFPS->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarRenderFPS_click,this));

	CEGUI::RadioButton * radMenuBarOptRise = (CEGUI::RadioButton*) CEGUI::WindowManager::getSingleton().getWindow("MenuBar/fraDeform/optRise");
	radMenuBarOptRise->subscribeEvent(CEGUI::RadioButton::EventMouseButtonDown,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarOptRise_click,this));

	CEGUI::Window* btnMenuBarOptLower = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/fraDeform/optLower");
	btnMenuBarOptLower->subscribeEvent(CEGUI::RadioButton::EventMouseButtonDown,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarOptLower_click,this));

	CEGUI::Window* btnMenuBarOptSmooth = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/fraDeform/optSmooth");
	btnMenuBarOptSmooth->subscribeEvent(CEGUI::RadioButton::EventMouseButtonDown,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarOptSmooth_click,this));

	CEGUI::Window* btnMenuBarOptPaint = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/fraPaint/optPaint");
	btnMenuBarOptPaint->subscribeEvent(CEGUI::RadioButton::EventMouseButtonDown,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarOptPaint_click,this));

	CEGUI::Window* btnMenuBarOptErase = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/fraPaint/optErase");
	btnMenuBarOptErase->subscribeEvent(CEGUI::RadioButton::EventMouseButtonDown,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarOptErase_click,this));

	CEGUI::Window* btnMenuBarOptPagingPaint = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/fraForest/optPaint");
	btnMenuBarOptPagingPaint->subscribeEvent(CEGUI::RadioButton::EventMouseButtonDown,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarOptPagingPaint_click,this));

	CEGUI::Window* btnMenuBarOptPagingErase = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/fraForest/optErase");
	btnMenuBarOptPagingErase->subscribeEvent(CEGUI::RadioButton::EventMouseButtonDown,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarOptPagingErase_click,this));

	CEGUI::Window* btnMenuBarOptMove = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/fraObj/optTranslate");
	btnMenuBarOptMove->subscribeEvent(CEGUI::RadioButton::EventMouseButtonUp,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarOptMove_click,this));

	CEGUI::Window* btnMenuBarOptRotate = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/fraObj/optRotate");
	btnMenuBarOptRotate->subscribeEvent(CEGUI::RadioButton::EventMouseButtonUp,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarOptRotate_click,this));

	CEGUI::Window* btnMenuBarOptScale = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/fraObj/optScale");
	btnMenuBarOptScale->subscribeEvent(CEGUI::RadioButton::EventMouseButtonUp,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarOptScale_click,this));

	CEGUI::Spinner* txtMenuBarcamVel = (CEGUI::Spinner*)CEGUI::WindowManager::getSingleton().getWindow("MenuBar/camVelocity");
	txtMenuBarcamVel->subscribeEvent(CEGUI::Spinner::EventValueChanged,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarCameraVelocity_change,this));

	CEGUI::Window* btnMenuBarQuit = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/btnQuit");
	btnMenuBarQuit->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarQuit_click,this));

	CEGUI::Window* wndMenuBarMouseLeaves = CEGUI::WindowManager::getSingleton().getWindow("MenuBar");
	wndMenuBarMouseLeaves->subscribeEvent(CEGUI::Window::EventMouseLeaves,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarMouseLeaves_click,this));
	//evtMenuBarMouseLeaves_click
	
	CEGUI::Combobox* cmbMapFileName = (CEGUI::Combobox*) CEGUI::WindowManager::getSingleton().getWindow("MenuBar/cmbMapFile");
	cmbMapFileName->subscribeEvent(CEGUI::Combobox::EventTextSelectionChanged,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarMapFileName_change,this));
	cmbMapFileName->subscribeEvent(CEGUI::Combobox::EventKeyUp,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarMapFileName_change,this));
	
	CEGUI::Window* btnMenuBarLoad = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/btnLoad");
	btnMenuBarLoad->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarLoad_click,this));
	
	CEGUI::Window* btnMenuBarSave = CEGUI::WindowManager::getSingleton().getWindow("MenuBar/btnSave");
	btnMenuBarSave->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&frmMenuBar::evtMenuBarSave_click,this));

}

void frmMenuBar::setup() {
	CEGUI::Window* w = CEGUI::WindowManager::getSingleton().getWindow("MenuBar");
	w->setVisible(true);

	CEGUI::FrameWindow* f;
	f = (CEGUI::FrameWindow*)CEGUI::WindowManager::getSingleton().getWindow("Paging");
	f->toggleRollup();
	
	f = (CEGUI::FrameWindow*)CEGUI::WindowManager::getSingleton().getWindow("Scene");
	f->toggleRollup();

	f = (CEGUI::FrameWindow*)CEGUI::WindowManager::getSingleton().getWindow("Objects");
	f->toggleRollup();

	f = (CEGUI::FrameWindow*)CEGUI::WindowManager::getSingleton().getWindow("Physics");
	f->toggleRollup();

	f = (CEGUI::FrameWindow*)CEGUI::WindowManager::getSingleton().getWindow("Terrain");
	f->toggleRollup();

/*
	CEGUI::Combobox* cmb = (CEGUI::Combobox*)CEGUI::WindowManager::getSingleton().getWindow("MenuBar/cmbMapFile2");
	//cmb->setReadOnly(true);

	const CEGUI::Image* sel_img = &CEGUI::ImagesetManager::getSingleton().getImageset("TaharezLook")->getImage("MultiListSelectionBrush");
	CEGUI::ListboxTextItem* itm1;
	itm1 = new CEGUI::ListboxTextItem("LT_DIRECTIONAL", 1);
	itm1->setSelectionBrushImage(sel_img);
	cmb->addItem(itm1);

	CEGUI::ListboxTextItem* itm2;
	itm2 = new CEGUI::ListboxTextItem("LT_POINT", 2);
	itm2->setSelectionBrushImage(sel_img);
	cmb->addItem(itm2);

	CEGUI::ListboxTextItem* itm3;
	itm3 = new CEGUI::ListboxTextItem("LT_SPOTLIGHT", 3);
	itm3->setSelectionBrushImage(sel_img);
	cmb->addItem(itm3);
*/
}

void frmMenuBar::fillMapList() {
	StringVectorPtr resourceNames;
	std::vector<Ogre::String>::const_iterator itResourceName;
	
	resourceNames = ResourceGroupManager::getSingleton().findResourceNames("ApeEngineMaps","../../Media/Maps/*.xml",false );
	itResourceName = resourceNames->begin();
	unsigned int i;
	i = 0;
	while ( itResourceName != resourceNames->end() )
	{
		//std::string meshName = itResourceName->substr(6,itResourceName->length() - 6);
		std::string meshName = itResourceName->c_str(); //itResourceName->c_str()
		//ResourceGroupManager::getSingleton().addResourceLocation(meshName, "FileSystem", "ApeEngineMaps");

		//////////////////////////////////////////////////////////////////////////////////////////////////////
		//////////////////////////////////////////////////////////////////////////////////////////////////////
		//////////////////////////////////////////////////////////////////////////////////////////////////////

		CEGUI::Combobox* cmb = (CEGUI::Combobox*)CEGUI::WindowManager::getSingleton().getWindow("MenuBar/cmbMapFile");
		//cmb->setReadOnly(true);
		const CEGUI::Image* sel_img = &CEGUI::ImagesetManager::getSingleton().getImageset("TaharezLook")->getImage("MultiListSelectionBrush");
		//CEGUI::ListboxTextItem* itm1;
		
		std::string str = (*itResourceName);
		string::size_type loc = str.find_last_of("/",str.length());
		if( loc != string::npos ) {
			//cout << "Found Omega at " << loc << endl;
			i++;
			std::string r = (*itResourceName).substr(loc + 1,str.length() - loc - 5);
			
			CEGUI::ListboxTextItem* itm1 = new CEGUI::ListboxTextItem(r, i);
			itm1->setSelectionBrushImage(sel_img);
			cmb->addItem(itm1);

		} else {
			//didnt find it
			return;
		}		
		
		//////////////////////////////////////////////////////////////////////////////////////////////////////
		//////////////////////////////////////////////////////////////////////////////////////////////////////
		//////////////////////////////////////////////////////////////////////////////////////////////////////
		
		++itResourceName;
	} 


}

/********************************************************************************
Misc.
*********************************************************************************/
bool frmMenuBar::evtMenuBarMouseLeaves_click(const CEGUI::EventArgs& e) {

	return true;
}
bool frmMenuBar::evtMenuBarSave_click(const CEGUI::EventArgs& e) {
	/*
	std::string map = GameSceneManager::getSingleton()->currentMapName;
	if(map!="") {
		GameSystemManager::getSingleton()->getXMLHandler()->initFile();
		//Save each system
		GameSystemManager::getSingleton()->getOgre()->saveToXML();
		static_cast<TerrainSystem*>(GameSystemManager::getSingleton()->getSystem("TerrainSystem"))->saveToXML();
		GameSystemManager::getSingleton()->getXMLHandler()->saveFile(map);
	}
	*/
	//const CEGUI::WindowEventArgs& wEventArgs = static_cast<const CEGUI::WindowEventArgs&>(e);
	//CEGUI::Combobox* cmb = static_cast<CEGUI::Combobox*>(wEventArgs.window);
	CEGUI::Combobox* cmb = (CEGUI::Combobox*)CEGUI::WindowManager::getSingleton().getWindow("MenuBar/cmbMapFile");

	GameSceneManager::getSingleton()->saveMap(cmb->getText().c_str());
	//saveSettings()
	
	return true;
}
bool frmMenuBar::evtMenuBarLoad_click(const CEGUI::EventArgs& e) {

	CEGUI::Combobox* cmb = (CEGUI::Combobox*)CEGUI::WindowManager::getSingleton().getWindow("MenuBar/cmbMapFile");
	GameSceneManager::getSingleton()->loadMap(cmb->getText().c_str());
	
	return true;
}
bool frmMenuBar::evtMenuBarMapFileName_change(const CEGUI::EventArgs& e) {
	const CEGUI::WindowEventArgs& wEventArgs = static_cast<const CEGUI::WindowEventArgs&>(e);
	CEGUI::Combobox* cmb = static_cast<CEGUI::Combobox*>(wEventArgs.window);
	GameSceneManager::getSingleton()->currentMapName = cmb->getText().c_str();
	return true;
}

/********************************************************************************
Quit
*********************************************************************************/
bool frmMenuBar::evtMenuBarQuit_click(const CEGUI::EventArgs& e) {
	GameSystemManager::getSingleton()->getInput()->shutDown = true;
	return true;
}

/********************************************************************************
Physics options
*********************************************************************************/
bool frmMenuBar::evtMenuBarPhysics_click(const CEGUI::EventArgs& e) {
	CEGUI::Window* w = CEGUI::WindowManager::getSingleton().getWindow("Physics");
	w->setVisible(true);
	return true;
}

/********************************************************************************
Network options
*********************************************************************************/
bool frmMenuBar::evtMenuBarMultiplayer_click(const CEGUI::EventArgs& e) {
	CEGUI::Window* w = CEGUI::WindowManager::getSingleton().getWindow("Client");
	w->setVisible(true);
	return true;
}

/********************************************************************************
Set normal rendering mode
*********************************************************************************/
bool frmMenuBar::evtMenuBarRenderNormal_click(const CEGUI::EventArgs& e) {
	GameSceneManager::getSingleton()->getCamera()->setPolygonMode(Ogre::PM_SOLID);
	return true;
}

/********************************************************************************
Set wireframe rendering mode
*********************************************************************************/
bool frmMenuBar::evtMenuBarRenderWireframe_click(const CEGUI::EventArgs& e) {
	GameSceneManager::getSingleton()->getCamera()->setPolygonMode(Ogre::PM_WIREFRAME);
	return true;
}

/********************************************************************************
Display FPS overlay
*********************************************************************************/
bool frmMenuBar::evtMenuBarRenderFPS_click(const CEGUI::EventArgs& e) {
	//GameSceneManager::getSingleton()->getSceneManager()->;
	bool r = !GameSystemManager::getSingleton()->getWindowHandler()->showDebugInfo;
	GameSystemManager::getSingleton()->getWindowHandler()->showDebugInfo = r;
	
	Overlay* o = OverlayManager::getSingleton().getByName("Core/DebugOverlay");
	if(r)
		o->show();
	else
		o->hide();

	return true;
}
/********************************************************************************
Terrain options
*********************************************************************************/
bool frmMenuBar::evtMenuBarBrushDeform_click(const CEGUI::EventArgs& e) {
	GameSceneManager::getSingleton()->setBrush(BRUSH_DEFORM);
	return true;
}
bool frmMenuBar::evtMenuBarBrushPaint_click(const CEGUI::EventArgs& e) {
	GameSceneManager::getSingleton()->setBrush(BRUSH_PAINT);
	return true;
}
bool frmMenuBar::evtMenuBarOptRise_click(const CEGUI::EventArgs& e) {
	GameSystemManager::getSingleton()->getTerrain()->riseTerrain = true;
	GameSystemManager::getSingleton()->getTerrain()->smoothTerrain= false;
	
	//static_cast<TerrainSystem*>(GameSystemManager::getSingleton()->getSystem("TerrainSystem"))->riseTerrain = true;
	//static_cast<TerrainSystem*>(GameSystemManager::getSingleton()->getSystem("TerrainSystem"))->smoothTerrain = false;
	return true;
}
bool frmMenuBar::evtMenuBarOptLower_click(const CEGUI::EventArgs& e) {
	GameSystemManager::getSingleton()->getTerrain()->riseTerrain = false;
	GameSystemManager::getSingleton()->getTerrain()->smoothTerrain= false;

	//static_cast<TerrainSystem*>(GameSystemManager::getSingleton()->getSystem("TerrainSystem"))->riseTerrain = false;
	//static_cast<TerrainSystem*>(GameSystemManager::getSingleton()->getSystem("TerrainSystem"))->smoothTerrain = false;
	return true;
}
bool frmMenuBar::evtMenuBarOptSmooth_click(const CEGUI::EventArgs& e) {

	GameSystemManager::getSingleton()->getTerrain()->riseTerrain = true;
	GameSystemManager::getSingleton()->getTerrain()->smoothTerrain= false;

	GameSceneManager::getSingleton()->setBrush(BRUSH_DEFORM);
	
	//static_cast<TerrainSystem*>(GameSystemManager::getSingleton()->getSystem("TerrainSystem"))->smoothTerrain = true;
	//static_cast<TerrainSystem*>(GameSystemManager::getSingleton()->getSystem("TerrainSystem"))->riseTerrain = false;
	
	return true;
}

/********************************************************************************
Object manipulation options
*********************************************************************************/
bool frmMenuBar::evtMenuBarObjects_click(const CEGUI::EventArgs& e) {
	CEGUI::Window* w = CEGUI::WindowManager::getSingleton().getWindow("Objects");
	w->setVisible(true);
	return true;
}
bool frmMenuBar::evtMenuBarBrushObject_click(const CEGUI::EventArgs& e) {
	GameSceneManager::getSingleton()->setBrush(BRUSH_OBJECT);
	return true;
}
bool frmMenuBar::evtMenuBarOptMove_click(const CEGUI::EventArgs& e) {
	gom_config.mode = MOVE_MODE;
	return true;
}
bool frmMenuBar::evtMenuBarOptRotate_click(const CEGUI::EventArgs& e) {
	gom_config.mode = ROTATE_MODE;
	return true;
}
bool frmMenuBar::evtMenuBarOptScale_click(const CEGUI::EventArgs& e) {
	gom_config.mode = SCALE_MODE;
	return true;
}

/********************************************************************************
Terrain painting options
*********************************************************************************/
bool frmMenuBar::evtMenuBarTerrain_click(const CEGUI::EventArgs& e) {
	CEGUI::Window* w = CEGUI::WindowManager::getSingleton().getWindow("Terrain");
	w->setVisible(true);
	return true;
}
bool frmMenuBar::evtMenuBarOptPaint_click(const CEGUI::EventArgs& e) {
	
	GameSystemManager::getSingleton()->getTerrain()->paintTerrain = true;

	//static_cast<TerrainSystem*>(GameSystemManager::getSingleton()->getSystem("TerrainSystem"))->paintTerrain = true;
	return true;
}
bool frmMenuBar::evtMenuBarOptErase_click(const CEGUI::EventArgs& e) {
	
	GameSystemManager::getSingleton()->getTerrain()->paintTerrain = false;
	
	//static_cast<TerrainSystem*>(GameSystemManager::getSingleton()->getSystem("TerrainSystem"))->paintTerrain = false;
	return true;
}

/********************************************************************************
Camera's velocity
*********************************************************************************/
bool frmMenuBar::evtMenuBarCameraVelocity_change(const CEGUI::EventArgs& e) {
	//GameSystemManager::getSingleton()->getTerrain()->paintTerrain = false;
	
	const CEGUI::WindowEventArgs& wEventArgs = static_cast<const CEGUI::WindowEventArgs&>(e);
	CEGUI::Spinner* spn = static_cast<CEGUI::Spinner*>(wEventArgs.window);

	CVelocity *obj_vel = dynamic_cast<CVelocity*>(GameObjectManager::getSingleton()->getGO("Camera")->getComponent("CVelocity"));
	if(obj_vel)
		obj_vel->Velocity = atof(spn->getText().c_str());

	sky_config.camVel = atof(spn->getText().c_str());
	return true;
}

/********************************************************************************
Display Scene edit window
*********************************************************************************/
bool frmMenuBar::evtMenuBarScene_click(const CEGUI::EventArgs& e) {
	
	CEGUI::Window* wndScene = CEGUI::WindowManager::getSingleton().getWindow("Scene");
	wndScene->setVisible(true);

	return true;
}

/********************************************************************************
Paged geometry options
*********************************************************************************/
bool frmMenuBar::evtMenuBarPaging_click(const CEGUI::EventArgs& e) {
	CEGUI::FrameWindow* w = (CEGUI::FrameWindow*)CEGUI::WindowManager::getSingleton().getWindow("Paging");
	w->setVisible(true);
	return true;
}
bool frmMenuBar::evtMenuBarBrushPaging_click(const CEGUI::EventArgs& e) {
	GameSceneManager::getSingleton()->setBrush(BRUSH_FOLIAGE);
	return true;
}
bool frmMenuBar::evtMenuBarOptPagingPaint_click(const CEGUI::EventArgs& e) {
	PagingConfig.paintMode = true;
	PagingConfig.eraseMode = false;
	return true;
}
bool frmMenuBar::evtMenuBarOptPagingErase_click(const CEGUI::EventArgs& e) {
	PagingConfig.paintMode = false;
	PagingConfig.eraseMode = true;
	return true;
}

